package com.health.api.config;


import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.health.api.fallback.UserClientFallback;
import feign.Logger;
import feign.codec.Decoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringDecoder;
import org.springframework.context.annotation.Bean;
import org.springframework.http.codec.cbor.Jackson2CborDecoder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;


/**
 * @author zhexueqi
 * @ClassName DefaultFeignConfig
 * @since 2024/5/12    19:18
 */
public class DefaultFeignConfig {

    @Bean
    public Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

    @Bean
    public Decoder feignDecoder() {
        ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(new MappingJackson2HttpMessageConverter());
        return new SpringDecoder(objectFactory);
    }

    @Bean
    public UserClientFallback itemClientFallback() {
        return new UserClientFallback();
    }

}
